home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
StepZkrolly demo ƒ
/
StepZkrolly.c
next >
Wrap
Text File
|
1995-01-17
|
3KB
|
116 lines
//• C translation from Pascal source file: Zkrolly.p
//• main Zkrolly;
#include "SAT.h"
extern void InitXprite(void);
extern pascal void SetupXprite(SpritePtr me);
extern pascal void HandleXprite(SpritePtr me);
extern void InitZprite(void);
extern pascal void SetupZprite(SpritePtr me);
extern pascal void HandleZprite(SpritePtr me);
SpritePtr ignoresp, zp;
WindowPtr Zwind;
Rect r;
enum {
scrollSizeH = 250,
scrollSizeV = 200
};
Point nowOff = {0,0};
#define max(x, y) (x>y?x:y)
#define min(x, y) (x>y?y:x)
#define abs(x) ((x)>0?(x):-(x))
pascal Boolean Zteppy()
{
Rect srcRect;
Point where;
where = zp->position;
where.h -= (scrollSizeH >> 1);
where.v -= (scrollSizeV >> 1);
if (where.h < 0)
where.h = 0;
if (where.v < 0)
where.v = 0;
if (where.h + scrollSizeH > gSAT.offSizeH)
where.h = gSAT.offSizeH - scrollSizeH;
if (where.v + scrollSizeV > gSAT.offSizeV)
where.v = gSAT.offSizeV - scrollSizeV;
if ((abs(where.h - nowOff.h) > scrollSizeH / 3) || (abs(where.v - nowOff.v) > scrollSizeV / 3))
do
{
if (nowOff.h > where.h)
nowOff.h = max(nowOff.h - 5, where.h);
if (nowOff.h < where.h)
nowOff.h = min(nowOff.h + 5, where.h);
if (nowOff.v > where.v)
nowOff.v = max(nowOff.v - 5, where.v);
if (nowOff.v < where.v)
nowOff.v = min(nowOff.v + 5, where.v);
SATSetPortScreen();
SetOrigin(nowOff.h, nowOff.v);
srcRect = gSAT.wind.port->portRect;
CopyBits(&gSAT.offScreen.port->portBits, &gSAT.wind.port->portBits, &srcRect, &srcRect, srcCopy, nil);
}
while ((nowOff.h != where.h) || (nowOff.v != where.v));
}
void SetupZwind()
{
Rect zr;
SysEnvRec wrld;
//• Since SAT hasn't been initialized, we can't use gSAT.colorFlag but
//• have to check environs ourselves.
if ( noErr != SysEnvirons(1, &wrld))
;//• ignore errors.
SetRect(&zr, 20, 30, 20 + scrollSizeH, 30 + scrollSizeV);
if ( wrld.hasColorQD )
Zwind = NewCWindow(0L, &zr, "\p", false, plainDBox, (WindowPtr)-1L, false, 0);
else
Zwind = NewWindow(0L, &zr, "\p", false, plainDBox, (WindowPtr)-1L, false, 0);
}
main ()
{
SATInitToolbox();
SetupZwind ();
SetRect(&r, 0, 0, 510, 340);
SATCustomInit(128, 129, &r, Zwind, 0L, false, false, false, true, false);
InitXprite ();
InitZprite ();
ShowWindow(gSAT.wind.port);
SelectWindow(gSAT.wind.port);
zp = SATNewSprite(0, 90, 70, &SetupZprite);
ignoresp = SATNewSprite(0, 120, 100, &SetupXprite);
ignoresp = SATNewSprite(0, 200, 160, &SetupXprite);
SATSoundOff();
SATRedraw();
SATSetPortScreen();
do
{
SATRun(true);
Zteppy();
} while (! Button ());
//• WARNING! It seems like we mess up the current device somewhere.
//• Probably a bug in SAT (where the device setting isn't perfect
//• yet). Let's set port and device to something nice and safe!.
SATSetPortScreen();
/* Finally, make sure we dispose of the sound channel. */
SATSoundShutup();
}